const path = require('path');

const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  configureWebpack: {
    resolve: {
      fallback: {
        fs: false,
        crypto: require.resolve("crypto-browserify")
      }
    },
    plugins: [new NodePolyfillPlugin()],
  },
  chainWebpack: webpackConfig => {
    webpackConfig.module
      .rule('wroker')
      .test(/\.worker\.js$/)
      .use('worker-loader')
      .loader('worker-loader')
      .end();
    webpackConfig.module.rule('js').exclude.add(/\.worker\.js$/);
    webpackConfig.module
      .rule('js')
      // .include.add('packages')
      .include.add(path.resolve(__dirname, './packages'))
      .end()
      .use('babel')
      .loader('babel-loader')
      .tap(options => {
        return options;
      });
  },
  devServer: {
    port: 8081
  }
})
